//
//  TodoTableViewCell.m
//  RoadMaintain
//
//  Created by 岳学坤 on 2017/2/28.
//  Copyright © 2017年 岳学坤. All rights reserved.
//

#import "TodoTableViewCell.h"
@interface TodoTableViewCell ()
@property (nonatomic,strong)UILabel *statusLab,*titleLab,*timeLab;
@end
@implementation TodoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = MAIN_Color;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUI];
    }
    return self;
}
- (void) setUI{
    self.statusLab = [[UILabel alloc]init];
    self.statusLab.backgroundColor= [PublicMethod colorWithHexString:@"#f36d64" andAlpha:1];
    self.statusLab.layer.cornerRadius = 4;
    self.statusLab.layer.masksToBounds = YES;
    self.statusLab.textAlignment = 1;
    self.statusLab.text = @"维修通知";
    self.statusLab.textColor = Bai_Color;
    self.statusLab.font = [UIFont systemFontOfSize:10*ZitiRate];
    [self.contentView addSubview:self.statusLab];
    [self.statusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(7*HeightRate);
        make.height.mas_equalTo(16*HeightRate);
        make.left.mas_equalTo(15*WidthRate);
        make.width.mas_equalTo(45*WidthRate);
    }];
    self.timeLab = [[UILabel alloc]init];
    self.timeLab.text = @"2017-09-08";
    self.timeLab.textColor = Bai_Color;
    self.timeLab.font = [UIFont systemFontOfSize:10*ZitiRate];
    self.timeLab.textAlignment = 2;
    [self.contentView addSubview:self.timeLab];
    CGSize size = [self.timeLab sizeThatFits:CGSizeMake(MAXFLOAT, 30*HeightRate)];
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.right.mas_equalTo(-15*WidthRate);
        make.width.mas_equalTo(size.width);
    }];
    
    self.titleLab = [[UILabel alloc]init];
    self.titleLab.text = @"您有一份维修通知单请及时处理。";
    self.titleLab.font = [UIFont systemFontOfSize:10*ZitiRate];
    self.titleLab.textColor = Bai_Color;
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(65*WidthRate);
        make.right.equalTo(self.timeLab.mas_left).offset(-5*WidthRate);
    }];
}
- (void)addValue:(NSDictionary *)dic{
    self.timeLab.text = [dic[@"sendDate"] substringToIndex:10];
    self.titleLab.text = dic[@"title"];
    if ([[NSString stringWithFormat:@"%@",dic[@"billName"]] isEqualToString:@"维修通知"]) {
        self.statusLab.text = @"维修通知";
        self.statusLab.backgroundColor= [PublicMethod colorWithHexString:@"#f36d64" andAlpha:1];
    }else{
        self.statusLab.text = @"验收通知";
        self.statusLab.backgroundColor= [PublicMethod colorWithHexString:@"#00ce9b" andAlpha:1];
    }
}
@end
